﻿namespace TfsCloudDeploy.Workflow.Core
{
    using System;
    using System.ComponentModel;
    using TfsCloudDeploy.Workflow.Core.Activities;

    /// <summary>
    /// Represents a target transform's metadata, specifically the source file name and the corresponding transform file path.
    /// </summary>
    [Serializable, TypeConverter(typeof(TargetTransformConverter))]
    public class TargetTransform
    {
        public TargetTransform()
        {

        }

        public TargetTransform(string sourceFileName, string transformFilePath)
            : this()
        {
            this.SourceFileName = sourceFileName;
            this.TransformFilePath = transformFilePath;
        }

        /// <summary>
        /// The name of the source file to be transformed (e.g.: web.config or MyApp.exe.config).
        /// </summary>
        [Browsable(true), RefreshProperties(RefreshProperties.All), SRDisplayName(typeof(ExtendedWorkflowResources), ExtendedWorkflowResources.SourceFileNameDisplayName), SRDescription(typeof(ExtendedWorkflowResources), ExtendedWorkflowResources.SourceFileNameDescription)]
        public string SourceFileName { get; set; }

        /// <summary>
        /// The path to the transform file under the transform root (e.g.: websites/MVCapp1/web.prod.config or services/MyService1/myservice1.exe.prod.config).
        /// </summary>
        [Browsable(true), RefreshProperties(RefreshProperties.All), SRDisplayName(typeof(ExtendedWorkflowResources), ExtendedWorkflowResources.TransformFilePathDisplayName), SRDescription(typeof(ExtendedWorkflowResources), ExtendedWorkflowResources.TransformFilePathDescription)]
        public string TransformFilePath { get; set; }

        public override string ToString()
        {
            return string.Format("Source File Name: {0} - Transform File Path: {1}",
                this.SourceFileName,
                this.TransformFilePath);
        }
    }
}
